<?php

namespace App\Jobs;

use App\Models\UserRead;
use App\Services\ArticleWeightService;
use App\Services\ReadStoreService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class ReadLogMigrate implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    private $login_uid;
    private $fake_uid;

    /**
     * ReadLogMigrate constructor.
     * @param $login_uid
     * @param $un_login_uid
     */
    public function __construct($login_uid, $fake_uid)
    {
        $this->login_uid = $login_uid;
        $this->fake_uid = $fake_uid;
    }

    /**
     * Execute the job.
     * @link https://shimo.im/mindmaps/y6ydprxxxJKCggPx/
     * @return void
     */
    public function handle()
    {
        $content = UserRead::where('uid', $this->fake_uid)->value('content');
        if ($content) {
            $read_article_ids = rtrim(ltrim($content, ','), ',');
            ReadStoreService::handle($this->login_uid, $read_article_ids, $this->fake_uid,true);
        }
    }
}
